package demo2;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardGame {
 public static final String[] suits = {"♥","♠","♣","♦"};

 public List<card> buyCard(){
     List<card> cards = new ArrayList();
     for(int i = 0 ; i < 4;i++){
         for(int j = 1 ; j < 14 ; j++){
             String suit = this.suits[i];
             int rank = j;
             card card = new card(rank,suit);
             cards.add(card);
         }
     }
     return cards;
 }
 public List<card> shuffle(List<card> cards){
     Random random = new Random();
     for(int i = cards.size() - 1; i > 0 ;i--){
         int ret = random.nextInt(i) ;
         swap(cards,i,ret);
     }
     return cards;
 }
 public void swap(List<card> cards,int i ,int ret){
     card tem = cards.get(i);
     cards.set(i,cards.get(ret));
     cards.set(ret,tem);
 }
}
